![]() |
FSpCreateResFile |
||||
Header: | Resources.h | Carbon status: | Supported | |
Creates an empty resource fork using a file system specification (FSSpec) record.
void FSpCreateResFile ( const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag );
A pointer to a file system specification structure that indicates the name and location of the file whose resource fork is to be created. The file system specification record for files and directories is defined by the FSSpec data type.
Certain File Manager functions—those that open a file’s data fork—also take a file system specification record as a parameter. You can use the same FSSpec record in Resource Manager functions that create or open the file’s resource fork.
If the file specified by the file system specification record doesn’t already exist (that is, if it has neither a data fork nor a resource fork), the function creates a resource file—that is, a resource fork, including a resource map. In this case the file has a zero-length data fork. The function also sets the creator, type, and script code fields of the file’s catalog information record to the specified values.
If the file specified by the file system specification record already exists and includes a resource fork with a resource map, the function does nothing. If the data fork of the file specified by the file system specification record already exists but the file has a zero-length resource fork, the function creates an empty resource fork and resource map for the file; it also changes the creator, type, and script code fields of the catalog information record of the file to the specified values.
If your application uses Standard File Package functions, note that the StandardPutFile function returns a standard file reply record that contains a file system specification record in the sfFile field.
The signature of the application creating the file. Whenever your application creates a document, it assigns a creator and a file type to that document. Typically your application sets its signature as the document’s creator.
The file type of the new file. You can set the file type to a type especially defined for your application or one of the existing general types, such as 'TEXT' for text (a stream of ASCII characters), or 'pref' for a preferences file.
The file type should be as descriptive of the file’s data format as possible. You should not use 'TEXT' as a file type unless the document contains plain ASCII characters.
The script code of the script system in which the Finder and standard file dialog boxes display the file’s name. For example, to specify the Roman script system, specify the constant smRoman in the scriptTag parameter.
Don’t use the resource fork of a file for data that is not in resource format. The Resource Manager assumes that any information in a resource fork can be interpreted according to the standard resource format described in this chapter.
The File Manager assumes that the first block of a file’s resource fork is part of the resource header and puts information there that it uses during scavenging—for example, after the user presses the Reset switch. For this reason, if you copy a resource file, the duplicate may not be exactly like the original.
This function is available only in System 7 and later versions of system software. If FSpCreateResFile is not available to your application, you can use the CreateResFile function or the HCreateResFile function. The HCreateResFile function is preferred over CreateResFile, which is an earlier version of HCreateResFile that is still supported but has more restricted capabilities.
Before you can work with the newly created file’s resource fork, you must use the FSpOpenResFile function to open it.
To check for errors, call the ResError function.
This function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.
Supported in Carbon. Available in Mac OS 8.1 and later when Carbon 1.0.2 or later is present.
© 2000 Apple Computer, Inc. — (Last Updated 5/8/2000)